package org.callisto.gui;

import java.awt.BorderLayout;
import java.awt.Font;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.callisto.EventType;
import org.callisto.model.Keyboard;

class Plotter extends Widget {
	
	private static final long serialVersionUID = 1L;
	JLabel hiY, midY, loY;

	public void setHi(float value) {
		hiY.setText(String.format("%.0f",value));
	}
	
	public void setMid(float value) {
		midY.setText(String.format("%.0f",value));
	}
	
	public void setLo(float value) {
		loY.setText(String.format("%.0f",value));
	}
	
	public Plotter(Keyboard keyboard, EventType eventType, int width, int height) {
	    super(keyboard, eventType, width, height);
		setLayout(new BorderLayout());
		add(new PlotterCanvas(keyboard, eventType, width, height),BorderLayout.CENTER);
		add(new JLabel("Graph: " + eventType, JLabel.CENTER),BorderLayout.NORTH);
		{
			JPanel yAxis = new JPanel();
			yAxis.setLayout(new BoxLayout(yAxis,BoxLayout.Y_AXIS));
			hiY = new JLabel("100%"); hiY.setFont(new Font("Arial",Font.PLAIN,10));
			yAxis.add(hiY);
			yAxis.add(Box.createVerticalGlue());
			midY = new JLabel("50%"); midY.setFont(new Font("Arial",Font.PLAIN,10));
			yAxis.add(midY);
			yAxis.add(Box.createVerticalGlue());
			loY = new JLabel("0%"); loY.setFont(new Font("Arial",Font.PLAIN,10));
			yAxis.add(loY);
			add(yAxis,BorderLayout.WEST);
		}
		add(new JLabel("X",JLabel.CENTER),BorderLayout.SOUTH);
		add(new JLabel("Legend"), BorderLayout.EAST);
	}
}
